import React,{ useEffect ,useState } from 'react';
import { message } from 'antd';
import CustomTable from '@/components/Table';
import cardStyles from '../../index.less';
import {getOperationRecord} from '@/service/order/index'

function OperationRecord(props:any) {
  const {info} = props
  const [orderData,setOrderData] = useState([])
  const [params, setParams] = useState({
		current: 1,
		size: 10,
	})
  const [loading, setLoading] = useState(false)
  const [total, setTotal] = useState(0)
  // 获取列表信息
  const getList =(page:any,id:any)=>{
    setLoading(true)
    const data = {
      orderCarId:id,
      current: page?.current,
      size: page?.size,
    }
    getOperationRecord(data).then((res:any)=>{
      if(res?.success){
        setOrderData(res?.data?.records)
        setTotal(res?.data?.total)
        setLoading(false)
      }else{
        setLoading(false)
      }
    })
  }
  useEffect(() => {
    getList(params,info?.id)
  }, [info]);
  
  const operationColumns = [
    { title: '操作人', dataIndex: 'logPersonname', align: 'center' },
    { title: '操作内容', dataIndex: 'logRemark', align: 'center' },
    { title: '操作时间', dataIndex: 'logTime', align: 'center' },
  ];
  return (
    <div className={cardStyles.card}>
      <p className={cardStyles.title}>操作记录</p>
      <CustomTable
         params={params}
         columns={operationColumns}
         pagination
         total={total}
         callback={(pagination: any) => {
           setParams(pagination)
           getList(pagination,info?.id)
         }}
         loading={loading}
         dataSource={orderData}
      />
    </div>
  );
}

export default OperationRecord;
